/************************************************************************
 * Copyright (c) 2008 Sergei Stolyarov
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Main window file, it contains implementation of main window methods.
 ************************************************************************/

#ifndef CONTROLWINDOW_H
#define CONTROLWINDOW_H

#include <QSystemTrayIcon>
#include <QDialog>

#include "ui_controlwindow.h"

class QMenu;
class QAction;
class QTimer;
class QShortcut;
class QIcon;

class ControlWindow : public QDialog
{
    Q_OBJECT

public:
    ControlWindow();

public slots:
    void updateControls();
    void reloadState();
    void reject();
    void show();
    void toggleShow();
    void preferencesDialog();
    void aboutDialog();
    void trayMenuActivated(QSystemTrayIcon::ActivationReason reason);
    void trayMenuBalloon(const QString & title, const QString & message, QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information, int millisecondsTimeoutHint = 10000);

protected:
    void closeEvent(QCloseEvent *event);

protected slots:
    void on_fanControlManual_clicked(bool checked = false);
    void on_fanControlAuto_clicked(bool checked = false);
    void on_fanSpeed_valueChanged(int i);

    void indicatorsStateChanged(unsigned int state);
    void quit();

private:
    /*
    static QString getParameterValue(const QString paramName);
    static bool setParameterValue(const QString paramName, QString paramValue);
    */

    QAction* toggleControlWindowAction;
    QAction* aboutAction;
    QAction* preferencesAction;
    QAction* quitAction;

    QMenu *trayIconMenu;
    QSystemTrayIcon* trayIcon;

    QSystemTrayIcon* numLockTrayIcon;
    QIcon* numLockOffIcon;
    QIcon* numLockOnIcon;

    QSystemTrayIcon* capsLockTrayIcon;
    QIcon* capsLockOnIcon;
    QIcon* capsLockOffIcon;

    int failedControls;
    QTimer *timer;
    Ui::ControlWindow ui;
};

#endif
